package com.xiaoyun.activiti01;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;

import java.io.InputStream;
import java.util.zip.ZipInputStream;

/**
 * 流程定义的部署
 * act_re_department 部署信息
 * acr_re_procdef 流程定义
 * act_ge_bytearray  流程定义的bpmn文件及png
 */
public class ActivitiDepartment {

//    //流程定义部署 zip文件实现
//    public static void main(String[] args) {
//
//        //创建ProcessEngine对象
//        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//        //得到RepositoryServic实例
//        RepositoryService repositoryService = processEngine.getRepositoryService();
//
//
//        InputStream is = ActivitiDepartment.class.getClassLoader().getResourceAsStream("diagram/holidayBpmn.zip");
//
//        ZipInputStream zipInputStream = new ZipInputStream(is);
//
//
//        //进行部署
//        Deployment deployment = repositoryService.createDeployment()
//                .addZipInputStream(zipInputStream)
//                .name("请假申请单流程")
//                .deploy();
//        //输出部署的一些信息
//        System.out.println(deployment.getName());
//        System.out.println(deployment.getId());
//    }


    //流程定义部署
    public static void main(String[] args) {
        //创建ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //得到RepositoryServic实例
        RepositoryService repositoryService = processEngine.getRepositoryService();
        //进行部署
        Deployment deployment = repositoryService.createDeployment()
                .addClasspathResource("diagram/holiday2.bpmn")
                .addClasspathResource("diagram/holiday2.png")
                .name("请假申请单流程")
                .deploy();
        //输出部署的一些信息
        System.out.println(deployment.getName());
        System.out.println(deployment.getId());
    }

}
